package com.sgai.zero_robot.database;


import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

import java.util.Objects;

@Entity(tableName = "detection_table")
public class ZeroDetectionEntity {

    @PrimaryKey(autoGenerate = true)
    private long id;
    //省份
    private String province;
    //市
    private String city;
    //线路名称
    private String lineName;
    //杆塔号
    private String towerNum;
    //安装值 1小号侧  2大号侧
    private int install;
    //相位 1A相  2B相  3C相
    private int phase;
    //绝缘子串  1外串  2中串  3内串
    private int insulator;
    //检零索引
    private int position;
    //检索时间
    private long time;
    //检索结果  -1未检测  0损坏  1正常
    private int state = -1;

    @Ignore
    public ZeroDetectionEntity(String province,String city,String lineName, String towerNum, int install, int phase, int insulator,int position,long time,int state) {
        this.province = province;
        this.city = city;
        this.lineName = lineName;
        this.towerNum = towerNum;
        this.install = install;
        this.phase = phase;
        this.insulator = insulator;
        this.position = position;
        this.time = time;
        this.state = state;
    }

    public ZeroDetectionEntity(int position,int state) {
        this.position = position;
        this.state = state;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getLineName() {
        return lineName;
    }

    public void setLineName(String lineName) {
        this.lineName = lineName;
    }

    public String getTowerNum() {
        return towerNum;
    }

    public void setTowerNum(String towerNum) {
        this.towerNum = towerNum;
    }

    public int getInstall() {
        return install;
    }

    public void setInstall(int install) {
        this.install = install;
    }

    public int getPhase() {
        return phase;
    }

    public void setPhase(int phase) {
        this.phase = phase;
    }

    public int getInsulator() {
        return insulator;
    }

    public void setInsulator(int insulator) {
        this.insulator = insulator;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Override
    public String toString() {
        return "ZeroDetectionEntity{" +
                "id=" + id +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", lineName='" + lineName + '\'' +
                ", towerNum='" + towerNum + '\'' +
                ", install=" + install +
                ", phase=" + phase +
                ", insulator=" + insulator +
                ", position=" + position +
                ", time=" + time +
                ", state=" + state +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true; // 引用相同
        if (o == null || getClass() != o.getClass()) return false; // 类型不同
        ZeroDetectionEntity that = (ZeroDetectionEntity) o;

        return install == that.install &&
                phase == that.phase &&
                insulator == that.insulator &&
                position == that.position &&
                Objects.equals(province, that.province) &&
                Objects.equals(city, that.city) &&
                Objects.equals(lineName, that.lineName) &&
                Objects.equals(towerNum, that.towerNum);
    }

    @Override
    public int hashCode() {
        return Objects.hash(province,city,lineName, towerNum, install, phase, insulator, position);
    }
}